ABC249 C - Just K
提出
code: python
import itertools
import string
n, k = map(int,input().split())
# 選んだ文字列に対して論理積をとっていく
# ちょうど 2 個 = 出現回数が2回
alp = list(string.ascii_lowercase)
ans = -1
for i in range(k, len(s)+1):
for j in itertools.combinations(s, i):
tmp = set()
for l in itertools.combinations(j, k):
for m in range(1, len(l)):
for n in res:
tmp.add(n)
if len(tmp) > ans:
ans = len(tmp)
print(ans)
解答
code: python
from collections import Counter
import itertools
n, k = map(int, input().split())
ans = 0
for p in itertools.product((True, False), repeat=n):
c = Counter()
for i in range(n):
res = 0
for ch, cnt in c.items():
if cnt == k:
res += 1
if ans < res:
ans = res
print(ans)
テーマ
メモ
提出
code: python
from itertools import product
from collections import Counter
n, k = list(map(int, input().split()))
ans = -1
for p in product(0, 1, repeat=n): pick = []
for i, _s in enumerate(s):
pick.append(_s)
c = Counter("".join(pick))
tmp = 0
for v in c.values():
if v == k:
tmp += 1
ans = max(ans, tmp)
print(max(0, ans))